home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / bin / gnatchop < prev    next >
Text File  |  1996-01-30  |  2KB  |  58 lines

  1. #!/bin/sh
  2. if test "$1" = ""
  3. then
  4.    echo "Usage : gnatchop [-krsw] filename [directory]"
  5.    echo " "
  6.    echo "  k         limit filenames to 8 characters"
  7.    echo "  r         generate Source_Reference pragmas"
  8.    echo "  s         generate a compilation script"
  9.    echo "  w         overwrite existing filenames"
  10.    echo "  filename  source file"
  11.    echo "  directory directory to place split files (default is ./)"
  12.    exit 1;
  13. fi
  14. parms=
  15. k8option=
  16. #
  17. # Scan through the options, checking for validity and especially looking for
  18. # the 'k' option since this will be used for the call to gcc to get the offset
  19. # information.
  20. #
  21. # modified by AS, 1994/06/06: use of getopts replaced by getopt since it
  22. # seems more common.
  23. #
  24. for c in `getopt krsw $*`
  25. do
  26.    case $c in
  27.       -k)       k8option="-k8"; shift;;
  28.       -r | -s | -w)  parms="$parms $c"; shift;;
  29.       --)       break;;
  30.       -\?)      echo "Usage : gnatchop [-krsw] filename [directory]"; exit 1;;
  31.    esac
  32. done
  33. #
  34. # Check that there is a filename argument after the option list, and that the
  35. # file actually exists.
  36. #
  37. if test "$1" = ""
  38. then
  39.    echo "missing filename"
  40.    echo "Usage : gnatchop [-krsw] filename [directory]"; exit 1
  41.    exit 1
  42. elif test ! -r $1
  43. then
  44.     echo "$1 not found"; exit 1
  45. fi
  46. # Call gnatf on the source filename argument with special options to generate
  47. # offset information. Then call the gnatchp program to actuall split the
  48. # source file in one file per compilation unit in the optional directory if
  49. # given otherwise in the current directory.
  50. #
  51. gnatf -s -u $k8option $1 >tmpfile
  52. if [ $? -ne 0 ] ; then
  53.    echo ""
  54.    echo "Warning: parse errors detected, chop might not be succesful"
  55. fi
  56. gnatchp $parms $1 $2 <tmpfile
  57. rm tmpfile
  58.